ADD_LIBRARY(g2o_cli_library ${G2O_LIB_TYPE}
  dl_wrapper.cpp dl_wrapper.h
  output_helper.cpp output_helper.h
  g2o_common.cpp g2o_common.h
  g2o_cli_api.h
)

SET_TARGET_PROPERTIES(g2o_cli_library PROPERTIES OUTPUT_NAME ${LIB_PREFIX}cli)

SET_PROPERTY(TARGET g2o_cli_library APPEND PROPERTY COMPILE_DEFINITIONS G2O_DEFAULT_TYPES_DIR_="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" G2O_DEFAULT_SOLVERS_DIR_="${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")

TARGET_LINK_LIBRARIES(g2o_cli_library core)
IF(UNIX)
  TARGET_LINK_LIBRARIES(g2o_cli_library dl)
ENDIF(UNIX)

ADD_EXECUTABLE(g2o_cli_application
  g2o.cpp)

TARGET_LINK_LIBRARIES(g2o_cli_application g2o_cli_library)

if(POLICY CMP0043)
cmake_policy(SET CMP0043 OLD)
endif()
SET_PROPERTY(TARGET g2o_cli_library APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG          G2O_LIBRARY_POSTFIX="${CMAKE_DEBUG_POSTFIX}")
SET_PROPERTY(TARGET g2o_cli_library APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO G2O_LIBRARY_POSTFIX="${CMAKE_RELWITHDEBINFO_POSTFIX}")
SET_PROPERTY(TARGET g2o_cli_library APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL     G2O_LIBRARY_POSTFIX="${CMAKE_MINSIZEREL_POSTFIX}")

SET_TARGET_PROPERTIES(g2o_cli_application PROPERTIES OUTPUT_NAME g2o${EXE_POSTFIX})


INSTALL(TARGETS g2o_cli_library g2o_cli_application
  RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
  LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)

FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.hpp")
INSTALL(FILES ${headers} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/g2o/apps/g2o_cli)
